package com.zzy.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzy.system.domain.GuanmaiCustomer;
import com.zzy.system.domain.GuanmaiSpu;
import com.zzy.system.mapper.GuanmaiCustomerMapper;
import com.zzy.system.mapper.GuanmaiSpuMapper;
import com.zzy.system.service.IGuanmaiCustomerService;
import com.zzy.system.service.IGuanmaiSpuService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GuanmaiSpuServiceImpl extends ServiceImpl<GuanmaiSpuMapper, GuanmaiSpu> implements IGuanmaiSpuService {

    private static final Logger log = LoggerFactory.getLogger(GuanmaiSpuServiceImpl.class);

    @Override
    public void saveSpuList(List<GuanmaiSpu> guanmaiSpuList) {
        if(guanmaiSpuList != null && !guanmaiSpuList.isEmpty()){

            this.saveBatch(guanmaiSpuList);
        }

    }

    @Override
    public void saveSpu(GuanmaiSpu guanmaiSpu) {
        QueryWrapper<GuanmaiSpu> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("spu_id", guanmaiSpu.getSpuId());
        this.baseMapper.delete(queryWrapper);
        this.save(guanmaiSpu);
    }
}